package com.example.demo3.controller;

import com.example.demo3.bean.User;
import com.example.demo3.dao.UserDao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    UserDao userDao;//创建一个userDao,用来访问数据库
    @RequestMapping("/alluser")
    public List<User> allUser(){
        List<User> all = userDao.findAll();//获取数据库表中的所有记录
        return all;
    }
}
